package com.kust.smarhome.background.controller;


import com.kust.smarhome.background.common.lang.Result;
import com.kust.smarhome.background.service.IShopService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.security.Principal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author iAuzre
 * @since 2021-07-31
 */
@RestController
@RequestMapping("/shop")
public class ShopController extends BaseController {

    @Resource
    private IShopService shopService;

    @GetMapping("/getCollectData")
    public Result getCollectData(Principal principal) {

        if (getUserPower(principal.getName()))
            return Result.fail(401, "权限不足", null);

        List<Map<String, String>> collectData = shopService.getCollectData();

        return Result.succ(collectData);
    }

}
